import pygame
import time
import sys
from pygame.locals import *
from point import Point

pygame.init()
pygame.display.set_caption('Paint')
# screen = pygame.display.set_mode( (800,400), pygame.FULLSCREEN )
screen = pygame.display.set_mode( (800,400) )
screen.fill((125,0,125))
point = Point()

spaceship = pygame.image.load('spaceship.png').convert_alpha()
angle = 1
while True:
    screen.fill((125,0,125))
    for event in pygame.event.get():
        if event.type == KEYDOWN:
            if event.key == K_ESCAPE:
                sys.exit()
            if event.key == K_RIGHT:
                point.rotate_right()
            if event.key == K_LEFT:
                point.rotate_left()
            if event.key == K_UP:
                point.speed_up()
            if event.key == K_DOWN:
                point.speed_down()
    point.move()
    try:
        time.sleep(0.001)
        angle = angle + 1
        painted_spaceship = pygame.transform.rotate(spaceship,point.angle)
    except Exception:
        pass
    screen.blit(painted_spaceship,(point.x,point.y))
    pygame.display.update()